<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="mallEtcCardRuleList" title="分配ETC卡卡号" actionUrl="mallEtcApplyController.do?etccardatagrid&shopid=${shopid}"
              idField="id" fit="true" queryMode="group" onClick="mallConfigEtcCradNoModule.rowclick">
   <t:dgCol title="编号" field="id" hidden="true"></t:dgCol>
   <t:dgCol title="店铺名称" field="shop.shopname"    width="120"></t:dgCol>
   <t:dgCol title="商品名称" field="product.productname"   width="120"></t:dgCol>
   <t:dgCol title="ETC供应商" field="etcSupplier.suppliername"   width="120"></t:dgCol>
   <t:dgCol title="ETC卡号" field="cardno" query="true"   width="120"></t:dgCol>
   <t:dgCol title="创建人" field="createuserid"   width="120"></t:dgCol>
   <t:dgCol title="创建时间" field="createtime" formatter="yyyy-MM-dd hh:mm:ss" query="true" queryMode="group" width="120"></t:dgCol>
   <t:dgCol title="状态" replace="未使用_0,已分配待审核_1,已使用_2" field="state"  query="true"  width="120"></t:dgCol>
  <%-- <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
   <t:dgDelOpt title="删除" url="mallEtcCardRuleController.do?del&id={id}" />--%>
   <%--<t:dgToolBar title="录入" icon="icon-add" funname="mallEtcCardRuleModule.saveview"></t:dgToolBar>--%>
<%--   <t:dgToolBar title="编辑" icon="icon-edit" url="mallEtcCardRuleController.do?addorupdate" funname="update"></t:dgToolBar>
   <t:dgToolBar title="查看" ic on="icon-search" url="mallEtcCardRuleController.do?addorupdate" funname="detail"></t:dgToolBar>--%>
  </t:datagrid>
  </div>
 </div>
<div region="east" style="width: 500px;" split="true">
    <div  region="north"  split="true"  class="easyui-panel"  style="padding-top: -100px;height: 10px" fit="true" border="false" id="function-panel">
           <div region="south"  style="height: 300px" split="true">
               <form id="mallConfigEtcCardNo" action="mallEtcApplyController.do?config">
                   <input type="hidden" name="id" value="${id}" >
                   <input type="hidden" name="etcCardNo" id="etc_cardno_val">
                   <input type="hidden" name="orderId" id="orderId" value="${orderId}">
                   <input type="hidden" name="etcCardRuleId" id="etc_cardrule_id">
                   <table style="width: 600px;" cellpadding="0" cellspacing="1" class="formtable">
                    <%--   <tr>
                           <td align="right">
                               <label class="Validform_label">
                                   店铺:
                               </label>
                           </td>
                           <td class="value">
                               <span id="shop_name"></span>
                           </td>
                       </tr>
                       <tr>
                           <td align="right">
                               <label class="Validform_label">
                                   商品:
                               </label>
                           </td>
                           <td class="value">
                               <span id="product_name"></span>
                           </td>
                       </tr>--%>
                       <tr>
                           <td align="right">
                               <label class="Validform_label">
                                   卡号:
                               </label>
                           </td>
                           <td class="value">
                               <span id="etccard_no"></span>
                           </td>
                       </tr>
                       <tr>
                           <td align="right">
                               <label class="Validform_label">
                                   领卡方式:
                               </label>
                           </td>
                           <td class="value">
                               <input id="receive_type" name="receiveType" value="${receivetype}" type="hidden">
                               <span >
                                <c:if test="${receivetype == 0}">
                                    现场领卡
                               </c:if>
                                <c:if test="${receivetype == 1}">
                                    邮寄
                               </c:if>
                               </span>
                           </td>
                       </tr>
                        <%--邮寄--%>
                        <c:if test="${receivetype == 1}">
                            <tr>
                                <td align="right">
                                    <label class="Validform_label">
                                        物流公司:
                                    </label>
                                </td>
                                <td class="value">
                                    <select name="expresscompanyId">
                                        <c:forEach var="expresscompany" items="${expresscompanys}">
                                            <option value="${expresscompany.id}">${expresscompany.name}</option>"
                                        </c:forEach>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <label class="Validform_label">
                                        快递单号:
                                    </label>
                                </td>
                                <td class="value">
                                    <input type="text" value="" id="expresscompany_no" datatype="*" name="expresscompanyNo">
                                    <span class="Validform_checktip"></span>
                                </td>
                            </tr>
                        </c:if>
                       <tr>
                           <td align="right">
                           </td>
                           <td class="value">
                               <input type="button" value="确定" id="save">
                               <span class="Validform_checktip"></span>
                           </td>
                       </tr>
                   </table>
               </form>
           </div>
    </div>

</div>

<script type="text/javascript">
    $(function() {
         mallConfigEtcCradNoModule.init();
    });
    var mallConfigEtcCradNoModule = (function(){

        /*初始化时间查询*/
        var initDate = function(){
            $("input[name='createtime_begin']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});});
            $("input[name='createtime_end']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});});
        }

        //表单验证
        var fromValidform = function(){
            $("#mallConfigEtcCardNo").Validform({
                tiptype:4,
                btnSubmit:"#save",
                ajaxPost:true,
                beforeSubmit:function(){
                    console.log($("#mallConfigEtcCardNo").serialize());
                    return true;
                },
                callback:function(data){
                    if(data.success==true){
                        $.messager.alert('成功',data.msg,"",function(){
                            window.document.location.href  = 'mallEtcApplyController.do?list'
                        });
                    }else{
                        $.messager.alert('错误',data.msg);
                    }
                }
            });
        }


        var module = {
            init :function(){
                initDate();
            },
            rowclick:function(rowIndex, rowData){
                $("#etccard_no").text(rowData.cardno);
                $("#etc_cardno_val").val(rowData.cardno);
                $("#etc_cardrule_id").val(rowData.id);
                fromValidform();
            }
        }
        return module;
    })();
</script>